package demo1;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-09-20
 * Time: 19:17
 */
/*
 *判断是否是闰年及各个月的天数

 */
public class Homework {
    public static void main(String[] args) {
        boolean isLeapYear, isCommonYear;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入想要判断的年份：");
        int year = scanner.nextInt();
        System.out.println("请输入想要判断的月份：");
        int month = scanner.nextInt();
        int days = 0;
            System.out.println("年份:" + year);
            System.out.println("月份：" + month);
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            System.out.println(year + "年是闰年");
        }else {
            System.out.println(year + "年不是闰年");
        }
            switch (month) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    days = 31;
                    System.out.println(year+"年"+month+"月有"+days+"天");
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    days = 30;
                    System.out.println(year+"年"+month+"月有"+days+"天");
                    break;
                case 2:
                    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {

                        System.out.println(year+"年"+month + "月有29天");

                    } else {

                        System.out.println(year+"年"+month + "月有28天");
                    }
                    break;
            }


    }
}
